Python SDK design for Http.File when it appears in non-multipart request body and response body (DO NOT MERGE)#3351
Draft
Python SDK design for Http.File when it appears in non-multipart request body and response body (DO NOT MERGE)#3351
Http.File when it appears in non-multipart request body and response body (DO NOT MERGE)#3351Conversation
Add a compact design note explaining why TypeSpec Http.File emitting IO[bytes] | bytes is backward compatible with legacy Swagger file APIs that accepted bytes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Http.File when it appears in non-multipart request body and response body (DO NOT MERGE)
johanste
reviewed
Feb 25, 2026
| ### Generated Python SDK | ||
|
|
||
| ```python | ||
| def download(self, **kwargs) -> bytes: |
Member
There was a problem hiding this comment.
This loses both content type and suggested file name. And it is a very dangerous operation for large amounts of data.
Member
Author
There was a problem hiding this comment.
For
@route("/base64")
@scenario
@scenarioDoc("""
Test base64 encode for bytes body.
Expected body:
"dGVzdA==" (base64 encode of test, in JSON string)
""")
op base64(): {
@header
contentType: "application/json";
@body
@encode(BytesKnownEncoding.base64)
value: bytes;
};
Python SDK API will decode it with base64 like
bytes can't work and only Http.File could reprensent this scenario.
That's my understanding why we need Http.File as response body.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.